package com.godofball.todo.utils;

import com.godofball.todo.contants.SystemConstants;

import java.util.Arrays;
import java.util.Date;

public class TaskUtil {
    private TaskUtil(){}

    /**
     * 判断任务是否已经完成
     * @param status
     * @return true完成 false未完成
     */
    public static final Boolean isWorkTask(String status) {
        if (status.equals(SystemConstants.TASK_NOT_START) ||
                status.equals(SystemConstants.TASK_OVERDUE) ||
                status.equals(SystemConstants.TASK_STARTED)) {
            return true;
        }
        return false;
    }

    public static final Boolean isDoneTask(String status) {
        if (status.equals(SystemConstants.TASK_COMPLETE_OVERDUE) ||
                status.equals(SystemConstants.TASK_COMPLETE_NORMAL) ||
                status.equals(SystemConstants.TASK_COMPLETE_AHEAD)) {
            return true;
        }
        return false;
    }

    /**
     * 用来获取未完成任务的状态
     * @param startTime
     * @param endTime
     * @return
     */
    public static final String getWorkTaskStatus(Date startTime,Date endTime){
        Date curTime = new Date();
        if (curTime.before(startTime)){
            return SystemConstants.TASK_NOT_START;
        } else if (curTime.after(endTime)) {
            return SystemConstants.TASK_OVERDUE;
        }else {
            return SystemConstants.TASK_STARTED;
        }
    }

    public static String getDoneTaskStatus(Date startTime, Date endTime, Date completeTime) {
        if (completeTime.before(startTime)){
            return SystemConstants.TASK_COMPLETE_AHEAD;
        } else if (completeTime.after(endTime)) {
            return SystemConstants.TASK_COMPLETE_OVERDUE;
        }else {
            return SystemConstants.TASK_COMPLETE_NORMAL;
        }
    }

    public static void main(String[] args) {
        Integer[] list=new Integer[7];
        Arrays.fill(list, 0);
        for (Integer i : list) {
            System.out.println(i);
            list[i]++;
            System.out.println(list[i]);
        }
    }
}
